/**
 *
 */
package com.ssyt.examinationsystem.service.impl;

import com.ssyt.examinationsystem.dao.IJudgeInfoDAO;
import com.ssyt.examinationsystem.dao.impl.JudgeInfoDAOImpl;
import com.ssyt.examinationsystem.entity.JudgeInfo;
import com.ssyt.examinationsystem.entity.PageBean;
import com.ssyt.examinationsystem.service.IJudgeInfoService;

import java.util.List;
import java.util.Map;

/**
 * @author Long.
 * @version 1.0
 * @className JudgeInfoServiceImpl
 * @since 2016年10月30日
 */
public class JudgeInfoServiceImpl implements IJudgeInfoService {
    IJudgeInfoDAO judgeDao = new JudgeInfoDAOImpl();

    /*
     * (non-Javadoc)
     *
     * @see
     * com.ssyt.examinationsystem.service.IJudegInfoService#addJudgeInfo(com
     * .ssyt.examinationsystem.entity.JudgeInfo)
     */
    @Override
    public int addJudgeInfo(JudgeInfo judge) {
        return judgeDao.addJudgeInfo(judge);
    }

    @Override
    public List<Map<String, Object>> getJudge() {
        return judgeDao.getJudge();
    }

    @Override
    public int updateJudge(JudgeInfo judge) {
        return judgeDao.updateJudge(judge);
    }

    @Override
    public int deleteJudge(String judgeId) {
        return judgeDao.deleteJudge(judgeId);
    }

    @Override
    public PageBean getJudgeByPage(PageBean page) {
        // 获取分页总记录数
        Integer totalRecords = judgeDao.getTotalCount();
        // 获取每页显示数
        Integer pageSize = page.getPageSize();
        // 获取当前页
        Integer currentPage = page.getCurrentPage();
        List<Map<String, Object>> judgeList = judgeDao.getJudgeByPage(page);
        // 创建一个分页对象
        PageBean pageBean = new PageBean(totalRecords, pageSize, currentPage);
        pageBean.setList(judgeList);

        return pageBean;
    }

}
